#include "TLKPlayMusic.h"
#include "ReportError.h"
#include "Timeline.h"
#include "SoundManager.h"
#include "TimeLineKeyFactory.h"

bool TLKPlayMusic::Load(File* f)
{
	if(!f->GetString(&m_FilePath))
	{
		f->ReportFileError(std::string("Can't find filepath"));
		return false;
	}
	if(!f->GetString(&m_MusicTag))
	{
		f->ReportFileError(std::string("Can't find music tag"));
	}
	if(!f->GetInteger(&m_Loops))
	{
		f->ReportFileError(std::string("Can't find amount of loops wanted"));
	}
	TheSound::Instance()->LoadMusic(m_FilePath, m_MusicTag);
	return true;


}


const char* TLKPlayMusic::GetTypeName() const
{
	return "TLKPlayMusic";
}

TimelineKey* CreateTLKPlayMusic()
{
	return new TLKPlayMusic;
}

void TLKPlayMusic::Exec()
{
	TheSound::Instance()->PlayMusic(m_MusicTag, m_Loops);
}

static bool l = TheTLKFactory::Instance()->AddToMap("TLKPlayMusic", CreateTLKPlayMusic);